<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<input type="text" name="">
	<script type="text/javascript">
		let inp = document.querySelector('input')

		//1.用户按下的时候触发
		// inp.onkeydown = function(){
		// 	console.log(this.value)
		// }


		//2.用户释放键盘的时候触发  推荐用这个
		inp.onkeyup = function(){
			console.log(this.value)
		}

		//禁用F12
		document.onkeydown = function(ev){
			//键盘码
			console.log(ev.keyCode)//F12的码是123
			if (ev.keyCode == 123) {
				ev.preventDefault()
				alert("不让你看")
			}
		}
	</script>
</body>
</html>